package com.example.usercenter.common;

import com.example.usercenter.enums.StatusEnum;
import lombok.Data;

/**
 * @Author hhf
 * @Date 2024/8/29
 * @Description
 */
@Data
public class Result {

    private int code;

    private String msg;

    private Object data;

    private String description;

    public Result() {
    }

    public Result(int code,String msg ,Object data,String description){
        this.code = code;
        this.msg = msg;
        this.data = data;
        this.description = description;
    }

    public static Result success(Object data){
        return new Result(StatusEnum.SUCCESS.getCode(),StatusEnum.SUCCESS.getMsg(),data,"");
    }


    public static Result fail(StatusEnum statusEnum,String msg){
        return new Result(statusEnum.getCode() ,msg,null,statusEnum.getMsg());
    }


    public static Result fail(int code,String msg,String description){
        return new Result(code,msg,null,description);
    }

}
